package com.cjack.frenchexcel.config;

import cn.hutool.core.thread.ExecutorBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;

@Slf4j
@Configuration
public class ThreadPoolConfig {

    public static final String defaultThreadPoolExecutor = "defaultThreadPoolExecutor";

    @Bean(defaultThreadPoolExecutor)
    public ThreadPoolExecutor defaultThreadPoolExecutor() {
        return ExecutorBuilder.create()
                .setCorePoolSize(5)
                .setMaxPoolSize(10)
                .setWorkQueue(new LinkedBlockingDeque<>(20000))
                .build();
    }
}
